// AuthButton.jsx
import { ref } from 'vue'
import { dataFind, getStorage } from '@zzcpt/zztool'

export default (props, { slots,attrs }) => {
  const isShow = ref(false)
  const auths = getStorage('userInfo.menus')

  if (props.auth && auths) {
    const obj = dataFind(auths, 'uri', props.auth)
    isShow.value = !!obj
  }

  return (
    isShow.value ? (
      <el-button {...attrs} type={props.type ?? 'primary'} loading={props.loading}>
        {slots.default?.()}
      </el-button>
    ) : null
  )
}
